![]() ![]() |
Don't call FrontWindow from VBL task
When I call
You'll have to come up with another method of getting the front window from your VBL task. You may want to keep a shadow copy of your application's window list in your application global area where your VBL task can get to it. How to save and restore window positionsDate Written: 11/16/93 Last reviewed: 11/16/93 How should my application save and restore its windows' positions? It is very important that you save the positions of windows that you open, so that the next time the user launches your application, the windows will go where they had them last. With data files, the window positions can be stored in either the resource or the data fork. If you have windows that aren't data windows (i.e., separate files), you should store information about their positions in a separate configuration file. (Storing them as a resource in your application is a bad idea, since they then 1) are not shareable on AppleShare (since resource forks are not) and 2) cannot save their positions if run from a CDROM or other protected volume.) Under System 7, this file should be put in the Preferences Folder inside the System Folder. Under System 6, this file should be put in the currently open system folder (this is guaranteed to be a local, non-shared volume as opposed to a server volume). See Technote TB535 - Finder Q&As: "FindFolder and Saving Application Preferences", for common code for Systems 6 and 7. Regardless of where you store window position information, your program should always check that the window's coordinates are reasonable before relocating the window there. That way users with two monitors who rearrange them, or users with large or multiple monitors who give their documents to users with single, small monitors, won't "lose" their windows when your program reopens them somewhere offscreen (for some reason users find offscreen windows hard to read). It's not enough to know some part of the window is on-screen. There must be title bar pixels on-screen for a user to drag the window (if a window that uses the standard WDEFs is opened with only the lower part of the window showing, there's no way to drag it!). So you need to calculate the title bar's rectangle. Start by finding the coordinates of the window's content region, which is fairly easy. Use the left and right coordinates as-is for the title bar's rectangle; use the top content region coordinate for the title bar's bottom coordinate. For the top of the title bar's rectangle, subtract the title bar height. For help calculating the title bar height (it varies internationally), see the next question, "How to determine Mac window title bar height for localization."
Once you've got the title bar's rectangle, call A generalized routine that returns a boolean indicating whether the title bar of the proposed coordinates of a window will be on-screen might look like (in C):
If How to determine Mac window title bar height for localizationDate Written: 8/12/91 Last reviewed: 11/16/93
How can my application determine a window title bar's height in pixels? Is
there a method similar to reading the global While the menu bar height can be easily found, determining the title bar height requires some effort. You are right to be concerned about the matter, as international versions of the system software may have various sizes of title bars. You should also note that Inside Macintosh: Macintosh Toolbox Essentials is incorrect in stating that, in the Roman script system, the standard document title bar is 20 pixels high: it is actually 19 pixels high.
In a nutshell, you need to find the difference between the top of the rectangle
of the window's content area, which is below the title bar, and the top of its
structure region. Be aware that the window has to be visible for its structure
and content regions to be valid. Use
Since neither content nor structure region is valid unless the window is
visible, you should make sure the window is visible before you examine these
regions. The easiest thing to do is to move the window way off-screen, show it
(use
For more help, look at DTS.Utilities in the Sample Code folder on the System 7 Golden Master CD, or in the System 7 Samples folder on subsequent Developer CDs (this folder includes a wide variety of other basic, useful routines as well). If you're calculating the title bar height for the purpose of confirming that saved window coordinates are reasonable (before relocating a window to those coordinates), see the previous question, "How to save and restore window positions." Code for implementing a Macintosh grow box but not scroll barsDate Written: 7/30/91 Last reviewed: 6/14/93
How do I draw a Macintosh grow box without the scroll bars? In the past I
avoided having the scroll bars by calling PenSize(-1, -1), which effectively
turns off the drawing of the scroll bar lines, and then calling
There is a very simple way to do this: Change the clipping region of the window
before you call
Just paste this code into your code and replace all calls to Macintosh tool palette windoid referenceDate Written: 7/30/91 Last reviewed: 8/1/91 Do you have any sample code or WDEFs for Macintosh tool palette windoids? Floating windows or windoids are not supported by Apple's system software. The best example has been published in the MacTutor article of April and May in 1988. (It's reprinted in The Definitive MacTutor, Volume 4, entitled "Tool Window Manager.") Its limitation is that it will only support a single window. There are also problem when using color QuickDraw regarding the Palette Manager, and we have not seen a good solution. Unfortunately, no standard WDEF has been issued by Apple, nor have standards been set for appearance and characteristics of floating windows. Those may be available in the future, but we presently have no guidelines. Implementing Macintosh floating windows or palettesDate Written: 8/15/91 Last reviewed: 8/15/91
We're having a lot of trouble with our floating palette which uses the global
variable There is no easy, built in, and supported way to do floating windows/palettes on the Macintosh. None of the solutions available are particularly elegant, but they do work.
Using the
A solution that should work well for you, but it is not incredibly elegant, is
to write "wrapper" functions for the Window Manager functions. Basically, your
application doesn't call many of the Window Manager functions
( MacTutor has had a couple of good articles on this topic:
How the system WDEF determines colorDate Written: 10/23/91 Last reviewed: 2/17/92
We're using
A more recent version of the Technote describes the way the system WDEF
determines color. The trick is to use Detaching a WDEF from its resource fileDate Written: 12/10/91 Last reviewed: 6/14/93 We sometimes need to close a resource file while still keeping a window open which is using a WDEF loaded from that resource file. We have been detaching the WDEF resource, which means that the WDEF handle in the window record is no longer a resource handle. What problems are we likely to have with this solution? Your solution is quite adequate. After a window is created, the system has no further need to use resource-manipulation calls on its window definition. As long as the handle is nonpurgeable, there should be no need to reload the data, so the Toolbox should be quite content with that state of affairs. Custom WDEFs in DAs not possibleDate Written: 3/30/92 Last reviewed: 5/21/92
I am writing a DA that uses a custom WDEF. Is there any way to get a window to
use a WDEF that is an owned resource? I tried giving the WDEF ID -16000 (DRVR
ID = 12, base ID 0) and using The owned resource mechanism and the WDEF numbering scheme conflicts in such a way that it's not possible to include custom WDEFs in DAs, since the DA mover will not move them unless they are in the owned resource range and the WDEF numbering scheme does not permit this. There's basically no workaround to this. Installing your WDEF in the system directly could cause numbering conflicts with additional WDEFs in future systems or other DAs doing the same thing. This is the reason for having owned resources. Macintosh DA with custom 'WDEF'Date Written: 7/24/90 Last reviewed: 6/14/93
Is it acceptable to write an installation program for a DA that uses a custom
Although the owned resource mechanism and the
First, number your
Next, when you open a window that needs your custom
Finally, show your window and it should be drawn using the custom Downloadables
|
Developer Documentation | Technical Q&As | Development Kits | Sample Code |